<?php

use Biz\service\SmallEnergy as sSmallEnergy;
use Biz\tools\SmallEnergyDes as tSmallEnergyDes;
use Doraemon\tools\log as tlog;
/**
 * @deprecated
 * Created by PhpStorm.
 * User: Dave
 * Date: 2018/6/6
 * Time: 16:28
 */

class SmallEnergyCallBackAction extends CallBackActionPlugin
{

    public function main()
    {
        $data = file_get_contents("php://input");
        $message = tSmallEnergyDes::getMessage($data);

        $message['CreateTime'] = date('Y-m-d H:i:s', $message['CreateTime']);

        $callbackResponse = json_encode($message, JSON_UNESCAPED_UNICODE);
        tlog::smallenergy_callback_debug(static::class, [
            'uri' => $this->getRequest()->getRequestUri(),
            'param' => $callbackResponse
        ]);

        sSmallEnergy::addMessage($message);

        $data = [
            "UpdateTime" => date('Y-m-d H:i:s'),
            "Success" => true,
        ];

        $this->setSuccess($data);
    }
}